#ifndef LCD_DISPLAY_H
#define LCD_DISPLAY_H

#include "stm32f10x.h"

// 页面索引枚举
typedef enum {
    PAGE_1,
    PAGE_2,
    PAGE_3,
    PAGE_MAX
} PageIndex;

// 8×16字符索引
typedef enum {
    INDEX_NUM0, INDEX_NUM1, INDEX_NUM2, INDEX_NUM3, INDEX_NUM4,
    INDEX_NUM5, INDEX_NUM6, INDEX_NUM7, INDEX_NUM8, INDEX_NUM9,
    INDEX_MAO, INDEX_DIAN, INDEX_V, INDEX_A, INDEX_m, INDEX_HENG,
    INDEX_U, INDEX_D, INDEX_S, INDEX_A_CHAR, INDEX_V_CHAR
} Char8x16Index;

// 16×16汉字索引
typedef enum {
    INDEX_HAN_DI, INDEX_HAN_ZHI, INDEX_HAN_DIAN, INDEX_HAN_YA,
    INDEX_HAN_CHI, INDEX_HAN_WEI, INDEX_HAN_HU, INDEX_HAN_FANG,
    INDEX_HAN_FOU, INDEX_HAN_GONG, INDEX_HAN_ZHUANG, INDEX_HAN_TAI,
    INDEX_HAN_LIU, INDEX_HAN_RONG, INDEX_HAN_LIANG, INDEX_HAN_BAN,
    INDEX_HAN_BEN, INDEX_HAN_TONG, INDEX_HAN_XIN, INDEX_HAN_DUAN,
    INDEX_HAN_ZHOU, INDEX_HAN_QI, INDEX_HAN_BEN_AN, INDEX_HAN_AN,
    INDEX_HAN_SHU, INDEX_HAN_CHU
} Char16x16Index;

// 动态显示数据结构
typedef struct {
    uint8_t address;           // 地址
    float batteryVoltage;      // 电池电压
    uint8_t isMaintenanceDischarge; // 维护放电状态(0:否,1:是)
    uint8_t powerSupplyStatus; // 供电状态(0:异常,1:正常)
    uint16_t dischargeCurrent; // 放电电流(mA)
    uint16_t batteryCapacity;  // 电池容量
    uint8_t versionMajor;      // 主版本号
    uint8_t versionMinor;      // 次版本号
    uint8_t communicationStatus; // 通信状态(0:断,1:通)
    int8_t cycleParam;         // 周期参数
    float safetyVoltage;       // 本安输出电压
    uint16_t safetyCurrent;    // 本安输出电流(mA)
} LcdDynamicData;

// 函数声明
void LCD_Init(void);
void LCD_Clear(void);
void LCD_DisplayChar_8x16(uint8_t page, uint8_t col, Char8x16Index index);
void LCD_DisplayChar_16x16(uint8_t page, uint8_t col, Char16x16Index index);
void LCD_DisplayNumber_8x16(uint8_t page, uint8_t col, float number, uint8_t intDigits, uint8_t decDigits);
void LCD_ShowPage(PageIndex page, const LcdDynamicData *data);
void LCD_UpdateDynamicData(LcdDynamicData *dest, const LcdDynamicData *src);

#endif // LCD_DISPLAY_H
